<template>
	<view class="page">
		<view class="certification_box">
			<view class="certification_name_box">
				<view class="certification_name">
					姓名：
				</view>
				<input type="text" v-model="formData.name" placeholder="请填写姓名" placeholder-style="color:#B3B3B3" />
			</view>
			<view class="certification_ID_box">
				<view class="certification_ID">
					身份证号：
				</view>
				<input type="text" v-model="formData.certification_ID" placeholder-style="color:#B3B3B3" placeholder="请填写身份证号" />
			</view>
			<view class="certification_pic_box">
				<view class="certification_pic_title">
					上传身份证照片：
				</view>
				<view class="certification_pic">
					<view class="certification_pic_left " @click="upload_img" data-face="0">
						<view class="upload_img vCenter">
							<image class="upImg" v-if="!formData.faceImage" src="../../../static/img/upImg.png"></image>
							<image class="result" v-if="formData.faceImage" :src="formData.faceImage" mode="widthFix"></image>
						</view>
					</view>
					<view class="certification_pic_right" @click="upload_img" data-face="1">
						<view class="upload_img vCenter">
							<image class="upImg" v-if="!formData.unfaceImage" src="../../../static/img/upImg.png"></image>
							<image class="result" v-if="formData.unfaceImage" :src="formData.unfaceImage" mode="widthFix"></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view  class="rz_sumbmit">认证</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				formData: {}
			};
		},
		methods: {
			handleChooseImg(e) {
				console.log('imageSrc:', e);
			},
			upload_img (e) {
				let _this = this
				let type = e.currentTarget.dataset.face
				uni.chooseImage({
				  count:1,
					success: (chooseImageRes) => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
							uni.getFileSystemManager().readFile({   // 转base64
							    filePath: tempFilePaths[0], //选择图片返回的相对路径
							    encoding: 'base64', //编码格式
							    success: res => { //成功的回调
								// 上传的图片路径
							        let base64 = 'data:image/jpeg;base64,' + res.data //不加上这串字符，在页面无法显示的哦
											if (type === '0') {
												_this.$set(_this.formData, 'faceImage', base64)
											} else  {
												_this.$set(_this.formData, 'unfaceImage', base64)
											}
							    }
							})	
					}
				});
			}
		}
	}
</script>
<style>
	page {
		background: #fff;
	}
</style>
<style lang="scss" scoped>
	.page {
		box-sizing: border-box;
		width: 100%;
		height: 100vh;
		background: #fff;
		.certification_box {
			background-color: #fff;
			padding: 33rpx;
			.certification_name_box {
				display: flex;
				justify-content: space-between;
				border-bottom: 1px solid rgba($color: #ddd, $alpha: .5);
				padding-bottom: 33rpx;
				margin-bottom: 33rpx;

				.certification_name {
					font-size: 32rpx;
					color: #B3B3B3;
				}

				input {
					flex: 1;
					padding-left: 20rpx;
					font-size: 32rpx;
					color: #565656;
				}
			}

			.certification_ID_box {
				display: flex;
				justify-content: space-between;
				border-bottom: 1px solid rgba($color: #ddd, $alpha: .5);
				padding-bottom: 33rpx;
				margin-bottom: 33rpx;

				.certification_ID {
					font-size: 32rpx;
					color: #B3B3B3;
				}

				input {
					flex: 1;
					padding-left: 20rpx;
					font-size: 32rpx;
					color: #565656;
				}
			}

			.certification_pic_box {
				line-height: 60rpx;

				.certification_pic_title {
					margin-bottom: 33rpx;
					font-size: 32rpx;
					color: #B3B3B3;
				}

				.certification_pic {
					display: flex;
					justify-content: space-between;
					.upload_img {
						width: 325rpx;
						height: 244rpx;
						.result {
							width: 100%;
							height: 100%;
						}
					}
					.certification_pic_left {
						width: 325rpx;
						height: 244rpx;
						background: #E9E9E9;
						.upImg {
							width: 125rpx;
							height: 125rpx;
						}
					}

					.certification_pic_right {
						width: 325rpx;
						height: 244rpx;
						background: #E9E9E9;
						.upImg {
							width: 125rpx;
							height: 125rpx;
						}
					}
				}

			}
		}

		.rz_sumbmit {
			position: fixed;
			left: 50%;
			transform: translateX(-50%);
			bottom: 117rpx;
			width:683rpx;
			height:100rpx;
			margin: 0 auto;
			line-height: 100rpx;
			background:rgba(54,138,255,1);
			border-radius:50rpx;
			border:1px solid rgba(151,151,151,1);
			color: #fff;
			font-size: 36rpx;
			text-align: center;
		}
	}
</style>
